package fr.sharpe.app.earthvisualizationproject.tools;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

class PropertiesFactory {

	private PropertiesFactory propertiesFactory = null;
	
	private static final String PROPERTIES_FILE_NAME 	= "EarthVisualization.properties";
	private static final String IMAGE_BASE_PATH 		= "dir.image";	

	private Properties properties;
	private String dirImage;

	public PropertiesFactory()
	{
		properties = new Properties();

		try {
			properties.load(new FileInputStream(new File(PROPERTIES_FILE_NAME)));

			setDirImage(properties.getProperty(IMAGE_BASE_PATH));
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public PropertiesFactory getInstance()
	{
		if(this.propertiesFactory == null)
		{
			this.propertiesFactory = new PropertiesFactory();
		}
		return this.propertiesFactory;
	}
	

	public void setDirImage(String dirImage) {
		this.dirImage = dirImage;
	}

	public String getDirImage() {
		return dirImage;
	}
}
